﻿using Time;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace Time
{

    [TestClass()]
    public class TimeTest
    {
        [TestMethod()]
        public void TimeConstructorTest()
        {
            int hours = 23;
            int minutes = 59;
            Time target = new Time(hours, minutes);
        }

        [TestMethod()]
        public void op_AdditionTest()
        {
            Time time = new Time(50, 20);
            int minutes = 150;
            Time expected = new Time(52, 50);
            Time actual;
            actual = (time + minutes);
            Assert.AreEqual(expected.Hours, actual.Hours);
            Assert.AreEqual(expected.Minutes, actual.Minutes);
        }

        [TestMethod()]
        public void op_SubtractionTest()
        {
            Time time = new Time(50, 20);
            int minutes = 150;
            Time expected = new Time(47, 50);
            Time actual;
            actual = (time - minutes);
            Assert.AreEqual(expected.Hours, actual.Hours);
            Assert.AreEqual(expected.Minutes, actual.Minutes);
        }

        [TestMethod()]
        public void op_SubtractionTestMinutesUnderZero()
        {
            Time time = new Time(2, 30);
            int minutes = 151;
            Time expected = new Time(0, -1);
            Time actual;
            actual = (time - minutes);
            Assert.AreEqual(expected.Hours, actual.Hours);
            Assert.AreEqual(expected.Minutes, actual.Minutes);
        }


        [TestMethod()]
        public void op_SubtractionTestHoursUnderZero()
        {
            Time time = new Time(2, 0);
            int minutes = 180;
            Time expected = new Time(-1, 0);
            Time actual;
            actual = (time - minutes);
            Assert.AreEqual(expected.Hours, actual.Hours);
            Assert.AreEqual(expected.Minutes, actual.Minutes);
        }

        [TestMethod()]
        public void ToStringTest()
        {
            int hours = 23;
            int minutes = 20;
            Time target = new Time(hours, minutes);
            string expected = "23:20";
            string actual;
            actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void op_DecrementTest()
        {
            Time time = new Time(5, 59);
            Time expected = new Time(5, 58);
            Time actual;
            actual = --(time);
            Assert.AreEqual(expected.Hours, actual.Hours);
            Assert.AreEqual(expected.Minutes, actual.Minutes);
        }

        [TestMethod()]
        public void op_IncrementTest()
        {
            Time time = new Time(5, 59);
            Time expected = new Time(6, 0);
            Time actual;
            actual = ++(time);
            Assert.AreEqual(expected.Hours, actual.Hours);
            Assert.AreEqual(expected.Minutes, actual.Minutes);
        }
    }
}

